package com.ys.enume.storage;


import java.util.ArrayList;
import java.util.List;

//FBA取消单
public class TccFbaCancelEnum {
	
	/*
	 * 货件状态
	 */
	public enum ShipmentState {
		NOT_BOXUP_NOT_PREPARE("未装箱/未配货", 0),
		NOT_BOXUP_YES_PREPARE("未装箱/已配货", 1),
		YES_BOXUP("已装箱", 2),
		WAIT_TRANSPORT("待转运", 3),
		YES_FINISHED("已完成", 4),
		;
		public String name;
		public Integer value;

		private ShipmentState(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (ShipmentState e : ShipmentState.values()) {
				if (e.value == value) {
					return e.name;
				}
			}
			return "";
		}

		//验证 state 是否在 checkState 中
		public static boolean stateIsPass(Integer state,List<ShipmentState> checkState){
			boolean isPass = false;
			for(ShipmentState shipmentState:checkState){
				if(state.equals(shipmentState.value)){
					isPass = true;
					break;
				}
			}
			return isPass;
		}

		//取消时 需要 计划单资金解冻 的状态
		public static List<ShipmentState> doPlanAmountThaw(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_NOT_PREPARE);//未装箱/未配货
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			return resList;
		}
		//取消时 需要 库存解冻 的状态
		public static List<ShipmentState> doStockThaw(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_NOT_PREPARE);//未装箱/未配货
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			return resList;
		}
		//取消时 需要 原库存出库 的状态
		public static List<ShipmentState> doStockOutByOld(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			return resList;
		}
		//取消时 需要 入库到新货位 的状态
		public static List<ShipmentState> doStockIn(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			resList.add(ShipmentState.YES_FINISHED);//已完成
			return resList;
		}
		//取消时 需要 费用收取： 仓储服务→手续费 的状态
		public static List<ShipmentState> doChargeTrouble(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			resList.add(ShipmentState.YES_FINISHED);//已完成
			return resList;
		}
		//取消时 需要 流水费用返还 的状态
		public static List<ShipmentState> doBackFlow(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			resList.add(ShipmentState.YES_FINISHED);//已完成
			return resList;
		}



		//暂不取消时 需要变更装箱单状态的 货件状态
		public static List<ShipmentState> doBoxUpCancelState(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.NOT_BOXUP_NOT_PREPARE);//未装箱/未配货
			resList.add(ShipmentState.NOT_BOXUP_YES_PREPARE);//未装箱/已配货
			resList.add(ShipmentState.YES_BOXUP);//已装箱
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			resList.add(ShipmentState.YES_FINISHED);//已完成
			return resList;
		}
		//暂不取消时 需要变更发货单状态的 货件状态
		public static List<ShipmentState> doDeliverCancelState(){
			List<ShipmentState> resList = new ArrayList<>();
			resList.add(ShipmentState.WAIT_TRANSPORT);//待转运
			resList.add(ShipmentState.YES_FINISHED);//已完成
			return resList;
		}

		//暂不取消时 根据货件状态获取原状态
		public static Integer getBoxUpOldStateByShipmentState(Integer shipmentState){
			Integer oldState = null;
			if(shipmentState.equals(ShipmentState.NOT_BOXUP_NOT_PREPARE.value)//未装箱/未配货
			|| shipmentState.equals(ShipmentState.NOT_BOXUP_YES_PREPARE.value)){//未装箱/已配货
				oldState = TccFbaBoxUpEnum.BoxState.NOT_UP.value;
			}
			if(shipmentState.equals(ShipmentState.YES_BOXUP.value)){//已装箱
				oldState = TccFbaBoxUpEnum.BoxState.YES_UP.value;
			}
			if(shipmentState.equals(ShipmentState.WAIT_TRANSPORT.value)//待转运
					|| shipmentState.equals(ShipmentState.YES_FINISHED.value)){//已完成
				oldState = TccFbaBoxUpEnum.BoxState.YES_PASS.value;
			}
			return oldState;
		}

		//暂不取消时 根据货件状态获取原状态
		public static Integer getDeliverOldStateByShipmentState(Integer shipmentState){
			Integer oldState = null;
			if(shipmentState.equals(ShipmentState.WAIT_TRANSPORT.value)){//待转运
				oldState = TccFbaDeliverEnum.Status.NOTRANSSHIPPED.value;
			}
			if(shipmentState.equals(ShipmentState.YES_FINISHED.value)){//已完成
				oldState = TccFbaDeliverEnum.Status.TRANSSHIPPED.value;
			}
			return oldState;
		}



	}



	/*
	 * 取消状态
	 */
	public enum CancelState {
		NOT_CANCEL("未取消", 0),
		YES_CANCEL("已取消", 1),
		;
		public String name;
		public Integer value;

		private CancelState(String name, Integer value) {
			this.name = name;
			this.value = value;
		}

		public static String getName(int value) {
			for (CancelState e : CancelState.values()) {
				if (e.value == value) {
					return e.name;
				}
			}

			return "";
		}
	}


}
